//
//  ViewController.m
//  小孩 对话框
//
//  Created by student on 16/3/17.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"
#import "MyButton.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *btn;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)btnPressed:(MyButton *)sender
{
    if(sender.addBtn != nil)
    {
        [sender.addBtn removeFromSuperview];
    }
    
    else
    {
        NSLog(@"%@",NSStringFromCGRect(sender.bounds));
        
        //    sender.clipsToBounds = YES;// 超出bounds范围的子视图不显示
        
        UIButton *btn = [[UIButton alloc] init];
        
        // 大小
        btn.bounds = CGRectMake(0, 0, 200, 200);
        // 中心点
        btn.center = CGPointMake(100, -100);
        
        [btn setBackgroundImage:[UIImage imageNamed:@"对话框.png"] forState:UIControlStateNormal];
        [btn setBackgroundImage:[UIImage imageNamed:@"小孩.png"] forState:UIControlStateHighlighted];
        
        [sender addSubview:btn];
        
        sender.addBtn = btn;
    }
 
}





@end
